package com.ibeeking.found.open.b.rest.controller.v1;

import com.ibeeking.found.open.api.common.dto.OrderAddResultDTO;
import com.ibeeking.found.open.api.common.dto.OrderAmountDTO;
import com.ibeeking.found.open.api.common.dto.OrderChargebackDTO;
import com.ibeeking.found.open.api.common.param.ErpPayTypeParam;
import com.ibeeking.found.open.api.common.param.OrderChargebackParam;
import com.ibeeking.found.open.api.common.query.OrderChargebackQuery;
import com.ibeeking.found.open.b.rest.service.IOrderService;
import com.ibeeking.found.open.service.common.param.OrderAddParam;
import com.ibeeking.found.open.service.common.query.OrderAmountQuery;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName OrderController控制器
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/v1/api/order")
public class OrderController {

    @Resource
    private IOrderService orderServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "订单金额查询")
    @PostMapping(value = "/queryAmount")
    public OrderAmountDTO queryOrderAmount(@RequestBody @Validated OrderAmountQuery query) {
        return orderServiceImpl.queryOrderAmount(query);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "订单支付成功通知")
    @PostMapping(value = "/add")
    public OrderAddResultDTO addOrder(@RequestBody @Validated OrderAddParam param) {
        return orderServiceImpl.addOrder(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "订单退货查询")
    @PostMapping(value = "/queryChargeback")
    public OrderChargebackDTO queryChargeback(@RequestBody @Validated OrderChargebackQuery query) {
        return orderServiceImpl.queryChargeback(query);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "订单退货通知")
    @PostMapping(value = "/chargeback")
    public Boolean orderChargeback(@RequestBody @Validated OrderChargebackParam param) {
        //订单退货通知-锁需要返还的积分等
        return orderServiceImpl.orderChargeback(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "订单取消退货通知")
    @PostMapping(value = "/cancelChargeback")
    public Boolean cancelChargeback(@RequestBody @Validated OrderChargebackParam param) {
        return orderServiceImpl.cancelChargeback(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "订单退货完成通知")
    @PostMapping(value = "/successChargeback")
    public Boolean successChargeback(@RequestBody @Validated OrderChargebackParam param) {
        //订单退货完成通知-扣减需要返还的积分等
        return orderServiceImpl.successChargeback(param);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "推送全量支付方式")
    @PostMapping(value = "/savePayType")
    public Boolean savePayType(@RequestBody @Validated List<ErpPayTypeParam> params) {
        return orderServiceImpl.savePayType(params);
    }
}
